<layout name="master"/>


<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
    <li><a href="index.html"><i class="fa fa-home"></i> Home</a></li>
    <li><a href="#">UI kit</a></li>
    <li><a href="#">Form</a></li>
    <li class="active">Elements</li>
</ul>
<div class="m-b-md">
    <h3 class="m-b-none">添加轮播图</h3>
</div>
<div class="row">
    <div class="col-sm-8">
        <section class="panel panel-default">
            <header class="panel-heading font-bold">添加轮播图</header>
            <div class="panel-body">
                <form role="form" method="post" action="">
                    <div class="form-group">
                        <label>轮播名称</label>
                        <input type="text" name='name' value="{$olddata['name']}" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>链接地址</label>
                        <input type="text" name='url' value="{$olddata['url']}" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>图片</label>
                        <input type="file" name="file_upload" id="file_upload1">
                        <div id="upload">
                            <if condition="isset($_GET['id'])">
                                <input type="hidden" name="picaddr" value="{$olddata['picaddr']}">
                                <img src="{$olddata['picaddr']}" width="100px" alt="">
                            </if>
                        </div>
                    </div>
                    <script>
                        $(function() {
                            $("#file_upload1").uploadify({
                                height        : 30,
                                'removeTimeout' : 0.2,
                                swf           : '__PUBLIC__/uploadify/uploadify.swf',
                                uploader      : '{:U("admin/banner/pic")}',
                                width         : 120,
                                'uploadLimit' : 1,
                                'buttonText' : '请选择图片',
                                'onUploadSuccess' : function(file, data, response) {
                                    str ='<li><img src="'+data+'" alt="" height="50px" >';
                                    str+='<a href="javascript:;" class="delimg" path="'+data+'">X<a/>';
                                    str+='<input type="hidden" name="picaddr" value="'+data+'"/>'
                                    str+='</li>';
                                    $('#upload').append(str);
                                },
                            });
                        });
                    </script>
                    <script>
                        $(function(){
                            $('#upload').on('click','.delimg',function(){
                                var path=$(this).attr('path');
                                that =$(this);
                                $.ajax({
                                    type: "POST",
                                    url: "{:u('admin/banner/delimg')}",
                                    data: {path:path},
                                    dataType: "json",
                                    success: function(msg){
                                        if(msg){
                                            that.parent('li').remove();
                                        }
                                    }
                                });
                            })
                        })
                    </script>
                    <div class="form-group">
                        <label>添加人</label>
                        <input name="adduser" value="{$olddata['adduser']}"  type="text" <if condition="isset($olddata['adduser'])"> readonly </if> name="adduser" class="form-control">
                    </div>
                    <button type="submit" class="btn btn-sm btn-success">提交</button>
                </form>
            </div>
        </section>
    </div>
</div>


